#include "OGLGeometryData.h"

OGLGeometryData::OGLGeometryData()
{
	position = glm::vec3(0.0f, 0.0f, 0.0f);
	setDefaults();
}

OGLGeometryData::OGLGeometryData(glm::vec3 pos)
{
	position = pos;
	setDefaults();
}

OGLGeometryData::~OGLGeometryData()
{
	// Nothing for now
}

glm::vec3 OGLGeometryData::GetObjectPosition(void)
{
	return position;
}

void OGLGeometryData::SetTranslationMatAbsolute(glm::vec3 newPos)
{
	position = newPos;
	translationMat = glm::translate(glm::mat4(1.0f), position);
}

void OGLGeometryData::SetTranslationMatRelative(glm::vec3 updatePos)
{
	position += updatePos;
	translationMat = glm::translate(glm::mat4(1.0f), position);
}

void OGLGeometryData::SetScaleMat(glm::vec3 scalingVec)
{
	scaleMat = glm::scale(glm::mat4(1.0f), scalingVec);
	srMatChange = true;
}

void OGLGeometryData::SetRotationMat(float angle, glm::vec3 rotationAxis)
{
	rotationMat = glm::rotate(angle, rotationAxis);
	srMatChange = true;
}

glm::mat4 OGLGeometryData::GetSRTMat(void)
{
	if(srMatChange)
	{
		srMat = rotationMat * scaleMat;
		srMatChange = false;
	}

	srtMat = translationMat * srMat;

	return srtMat;
}

void OGLGeometryData::setDefaults()
{
	scaleMat = glm::scale(1.0f, 1.0f, 1.0f);
	rotationMat = glm::rotate(0.0f, glm::vec3(1.0f, 0.0f, 0.0f));
	translationMat = glm::translate(position.x, position.y, position.z);
	srMatChange = true;
}